package com.hs.android.fortress.net;

import java.io.IOException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.protocol.HTTP;

import com.google.gson.JsonObject;

public class JSONPostCommand extends PostMethodCommand{
	private String mUrl;
	private JsonObject mParams;
	
	public JSONPostCommand(String path, JsonObject parmas) {
		mUrl = BASIC_URL + path;
		mParams = parmas;
	}
	
	@Override
	protected HttpPost makeHttpPost() throws IOException {
		
		HttpPost post = new HttpPost(mUrl);
		
		if(mParams != null){
			post.setHeader("Content-Type", AsyncNetworking.MIME_JSON);
			StringEntity se = new StringEntity(mParams.toString(),HTTP.UTF_8);
			post.setEntity(se);
		}
		return post;
	}

	public void setParams(Object params) {
		mParams = (JsonObject)params;
	}
	
	
}
